<template>
  <div class="sidebar">
    <div class="icon" @click="toggleMenu" @mouseover="showIcon" @mouseleave="hideIcon">
      <img
        src="https://s1.aigei.com/src/img/png/e0/e0a07cd80e09495ea59e715ad48eee7a.png?imageMogr2/auto-orient/thumbnail/!240x240r/gravity/Center/crop/240x240/quality/85/&e=1735488000&token=P7S2Xpzfz11vAkASLTkfHN7Fw-oOZBecqeJaxypL:wd_zsEt1SlJteq-Cg8QEGGppcXs="
        alt="icon"/>
    </div>
    <div class="menu" v-show="showMenu">
      <!-- menu items go here -->
    </div>
  </div>
</template>

<script>
import {ref} from 'vue';
import {gsap} from 'gsap';

export default {
  name: 'Sidebar',
  setup() {
    const showMenu = ref(false);
    const showIcon = () => {
      gsap.to('.icon', {scale: 1.2});
    };
    const hideIcon = () => {
      gsap.to('.icon', {scale: 1});
    };
    const toggleMenu = () => {
      showMenu.value = !showMenu.value;
    };
    return {
      showMenu,
      showIcon,
      hideIcon,
      toggleMenu,
    };
  },
};
</script>

<style>
.sidebar {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  z-index: 999;
}

.icon {
  position: relative;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: #333;
  cursor: pointer;
  transition: all 0.3s ease;
}

.icon img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
}

.menu {
  position: absolute;
  top: 50%;
  right: 100%;
  transform: translateY(-50%);
  width: 200px;
  height: 300px;
  background-color: #333;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  transition: all 0.3s ease;
  z-index: -1;
}

.menu li {
  margin-bottom: 10px;
  color: #fff;
  font-size: 18px;
  text-align: center;
  cursor: pointer;
}

.menu li:hover {
  text-decoration: underline;
}
</style>
